<?php
class test_category_model extends UnitTestCase 
{
	var $CI = '';
	
	function __construct() 
	{
		$this->CI =& get_instance();
		$this->CI->load->model('setup/install_model');
		$this->CI->load->model('category_model');
	}
	
	function setUp() 
	{
		$this->CI->install_model->table_categories(TRUE);
		$data = array(
					'cat_parent' => 0,
					'cat_name' => "Búsqueda's",
					'cat_uri' => 'cat',
					'cat_description' => 'Graphic and text based web counter scripts',
					'cat_display' => 'Y'
				);
		$var = $this->CI->category_model->add_category($data);
    }

    function tearDown() 
	{
        $this->CI->install_model->table_categories(TRUE);
    }
 
	function test_insert() 
	{
	   	$data = array(
					'cat_parent' => 0,
					'cat_name' => "Búsqueda's",
					'cat_uri' => 'cat',
					'cat_description' => 'Graphic and text based web counter scripts',
					'cat_display' => 'Y'
				);
		$var = $this->CI->category_model->add_category($data);
		$this->assertTrue($var);
		$data = array(
					'cat_parent' => 1,
					'cat_name' => "Child",
					'cat_uri' => 'cat',
					'cat_description' => 'Graphic and text based web counter scripts',
					'cat_display' => 'Y'
				);
		$var = $this->CI->category_model->add_category($data);
	}
	
	function test_edit()
	{
		$data = array(
					'cat_parent' => 0,
					'cat_name' => "Test's",
					'cat_uri' => "Búsqueda's",
					'cat_description' => 'Graphic and text based web counter scripts'
				);
		$var = $this->CI->category_model->edit_category(1, $data);
		$this->assertTrue($var);
	}
	
	function test_delete()
	{
		$var = $this->CI->category_model->delete_category(1);
		$this->assertTrue($var);
		$var = $this->CI->category_model->delete_category(2);
		$this->assertFalse($var);
	}
	
	function test_foriegn_uri()
	{
		$var = $this->CI->category_model->format_uri('áéíóúàèìòùñäëïöü');
		$this->assertEqual($var, 'aeiouaeiounaeiou');
		$var = $this->CI->category_model->format_uri('áéíóúüñ');
		$this->assertEqual($var, 'aeiouun');
	}
	
}
